package user

import (
	"go-interview-forum/model/user"
	"gorm.io/gorm"
)

func GitUserInfo(id int) (*user.User, error) {
	u := user.User{Model: gorm.Model{ID: uint(id)}}

	err := user.GetUserInfoById(&u)
	if err != nil {
		return nil, err
	}

	return &u, nil
}

func UpdateUserInfo(id int, nickname string, avatar string) error {
	u := user.User{
		Model:    gorm.Model{ID: uint(id)},
		Nickname: nickname,
		Avatar:   avatar,
	}

	err := user.UpdateUserInfo(&u)
	if err != nil {
		return err
	}

	return nil
}
